using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Resources;
using System.Windows.Forms;
using Infragistics.Win;
using Infragistics.Win.UltraWinDataSource;
using Infragistics.Win.UltraWinGrid;
using PluginFrame;

namespace ExperimentRuleEditor
{
	public class Rule_Editor : Form
	{
		private IContainer components;

		private Panel Rulepanel;

		private Button btDeleteCondition;

		private Button btAddCondition;

		private Button btDeleteRule;

		private Button btAddRule;

		private UltraGrid ultraGridRule;

		private Panel panel1;

		private Button btExpression;

		private IRuleItem m_LRuleItem = new RuleItem();

		protected IRuleEditorService mRuleEditorService;

		private int m_LConditionNum;

		private List<string> m_LListSelectCondition;

		private string m_LProjectName = "";

		private string[] m_LProjectType;

		protected IConfigurationService mConfigurationService;

		private readonly IPcrLogService mPcrLogService;

		private IApplication mApplication;

		private bool m_LMouseClickFlag;

		private UltraGridCell m_LSelectCell;

		private int m_LSelectCellIndex;

		private IConditionEditor m_LCopyCondition;

		private List<IConditionEditor> m_LListCopyCondition;

		private List<string> m_LListCopyIntepretation;

		private List<string> m_LListCopyItem;

		private string m_LCopyIntepretation;

		private ToolStripMenuItem menuRulePasteEditor;

		private bool m_LLocked;

		private int m_LCheck;

		private int m_LPattern;

		private int m_LTarget;

		private int m_LOperator;

		private string m_LValue;

		private int m_LExpressionCheck;

		private bool m_LTargetFlag;

		private bool m_LColorFlag;

		private bool m_LInitalCheckTargetFlag;

		private bool m_LInitalCheckColorFlag;

		private IPcrExperimentProject m_LPcrExperimentProject;

		protected ResourceManager mResourceManager;

		protected override void Dispose(bool disposing)
		{
			if (disposing && components != null)
			{
				components.Dispose();
			}
			base.Dispose(disposing);
		}

		private void InitializeComponent()
		{
			System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ExperimentRuleEditor.Rule_Editor));
			Infragistics.Win.Appearance appearance = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance2 = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance3 = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance4 = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance5 = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance6 = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance7 = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance8 = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance9 = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance10 = new Infragistics.Win.Appearance();
			Infragistics.Win.Appearance appearance11 = new Infragistics.Win.Appearance();
			this.Rulepanel = new System.Windows.Forms.Panel();
			this.ultraGridRule = new Infragistics.Win.UltraWinGrid.UltraGrid();
			this.panel1 = new System.Windows.Forms.Panel();
			this.btExpression = new System.Windows.Forms.Button();
			this.btDeleteCondition = new System.Windows.Forms.Button();
			this.btAddCondition = new System.Windows.Forms.Button();
			this.btDeleteRule = new System.Windows.Forms.Button();
			this.btAddRule = new System.Windows.Forms.Button();
			this.Rulepanel.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)this.ultraGridRule).BeginInit();
			this.panel1.SuspendLayout();
			base.SuspendLayout();
			this.Rulepanel.Controls.Add(this.ultraGridRule);
			this.Rulepanel.Controls.Add(this.panel1);
			resources.ApplyResources(this.Rulepanel, "Rulepanel");
			this.Rulepanel.Name = "Rulepanel";
			appearance.BackColor = System.Drawing.SystemColors.Window;
			appearance.BorderColor = System.Drawing.Color.White;
			resources.ApplyResources(appearance.FontData, "appearance31.FontData");
			resources.ApplyResources(appearance, "appearance31");
			appearance.ForceApplyResources = "FontData|";
			this.ultraGridRule.DisplayLayout.Appearance = appearance;
			this.ultraGridRule.DisplayLayout.BorderStyle = Infragistics.Win.UIElementBorderStyle.Solid;
			this.ultraGridRule.DisplayLayout.CaptionVisible = Infragistics.Win.DefaultableBoolean.False;
			appearance2.BackColor = System.Drawing.SystemColors.ActiveBorder;
			appearance2.BackColor2 = System.Drawing.SystemColors.ControlDark;
			appearance2.BackGradientStyle = Infragistics.Win.GradientStyle.Vertical;
			appearance2.BorderColor = System.Drawing.SystemColors.Window;
			resources.ApplyResources(appearance2.FontData, "appearance32.FontData");
			resources.ApplyResources(appearance2, "appearance32");
			appearance2.ForceApplyResources = "FontData|";
			this.ultraGridRule.DisplayLayout.GroupByBox.Appearance = appearance2;
			appearance3.ForeColor = System.Drawing.SystemColors.GrayText;
			resources.ApplyResources(appearance3.FontData, "appearance33.FontData");
			resources.ApplyResources(appearance3, "appearance33");
			appearance3.ForceApplyResources = "FontData|";
			this.ultraGridRule.DisplayLayout.GroupByBox.BandLabelAppearance = appearance3;
			this.ultraGridRule.DisplayLayout.GroupByBox.BorderStyle = Infragistics.Win.UIElementBorderStyle.Solid;
			appearance4.BackColor = System.Drawing.SystemColors.ControlLightLight;
			appearance4.BackColor2 = System.Drawing.SystemColors.Control;
			appearance4.BackGradientStyle = Infragistics.Win.GradientStyle.Horizontal;
			appearance4.ForeColor = System.Drawing.SystemColors.GrayText;
			resources.ApplyResources(appearance4.FontData, "appearance34.FontData");
			resources.ApplyResources(appearance4, "appearance34");
			appearance4.ForceApplyResources = "FontData|";
			this.ultraGridRule.DisplayLayout.GroupByBox.PromptAppearance = appearance4;
			this.ultraGridRule.DisplayLayout.MaxColScrollRegions = 1;
			this.ultraGridRule.DisplayLayout.MaxRowScrollRegions = 1;
			appearance5.BackColor = System.Drawing.SystemColors.Window;
			appearance5.ForeColor = System.Drawing.SystemColors.ControlText;
			resources.ApplyResources(appearance5.FontData, "appearance35.FontData");
			resources.ApplyResources(appearance5, "appearance35");
			appearance5.ForceApplyResources = "FontData|";
			this.ultraGridRule.DisplayLayout.Override.ActiveCellAppearance = appearance5;
			this.ultraGridRule.DisplayLayout.Override.BorderStyleCell = Infragistics.Win.UIElementBorderStyle.Dotted;
			this.ultraGridRule.DisplayLayout.Override.BorderStyleRow = Infragistics.Win.UIElementBorderStyle.Dotted;
			appearance6.BorderColor = System.Drawing.Color.Silver;
			appearance6.TextTrimming = Infragistics.Win.TextTrimming.EllipsisCharacter;
			resources.ApplyResources(appearance6.FontData, "appearance36.FontData");
			resources.ApplyResources(appearance6, "appearance36");
			appearance6.ForceApplyResources = "FontData|";
			this.ultraGridRule.DisplayLayout.Override.CellAppearance = appearance6;
			this.ultraGridRule.DisplayLayout.Override.CellPadding = 0;
			appearance7.BackColor = System.Drawing.SystemColors.Control;
			appearance7.BackColor2 = System.Drawing.SystemColors.ControlDark;
			appearance7.BackGradientAlignment = Infragistics.Win.GradientAlignment.Element;
			appearance7.BackGradientStyle = Infragistics.Win.GradientStyle.Horizontal;
			appearance7.BorderColor = System.Drawing.SystemColors.Window;
			resources.ApplyResources(appearance7.FontData, "appearance37.FontData");
			resources.ApplyResources(appearance7, "appearance37");
			appearance7.ForceApplyResources = "FontData|";
			this.ultraGridRule.DisplayLayout.Override.GroupByColumnAppearance = appearance7;
			resources.ApplyResources(appearance8, "appearance38");
			resources.ApplyResources(appearance8.FontData, "appearance38.FontData");
			appearance8.ForceApplyResources = "FontData|";
			this.ultraGridRule.DisplayLayout.Override.HeaderAppearance = appearance8;
			this.ultraGridRule.DisplayLayout.Override.HeaderStyle = Infragistics.Win.HeaderStyle.WindowsXPCommand;
			appearance9.BackColor = System.Drawing.SystemColors.Window;
			appearance9.BorderColor = System.Drawing.Color.Silver;
			resources.ApplyResources(appearance9.FontData, "appearance39.FontData");
			resources.ApplyResources(appearance9, "appearance39");
			appearance9.ForceApplyResources = "FontData|";
			this.ultraGridRule.DisplayLayout.Override.RowAppearance = appearance9;
			appearance10.ImageAlpha = Infragistics.Win.Alpha.UseAlphaLevel;
			resources.ApplyResources(appearance10.FontData, "appearance41.FontData");
			resources.ApplyResources(appearance10, "appearance41");
			appearance10.ForceApplyResources = "FontData|";
			this.ultraGridRule.DisplayLayout.Override.RowSelectorAppearance = appearance10;
			this.ultraGridRule.DisplayLayout.Override.RowSelectors = Infragistics.Win.DefaultableBoolean.True;
			appearance11.BackColor = System.Drawing.SystemColors.ControlLight;
			resources.ApplyResources(appearance11.FontData, "appearance40.FontData");
			resources.ApplyResources(appearance11, "appearance40");
			appearance11.ForceApplyResources = "FontData|";
			this.ultraGridRule.DisplayLayout.Override.TemplateAddRowAppearance = appearance11;
			this.ultraGridRule.DisplayLayout.ScrollBounds = Infragistics.Win.UltraWinGrid.ScrollBounds.ScrollToFill;
			this.ultraGridRule.DisplayLayout.ViewStyleBand = Infragistics.Win.UltraWinGrid.ViewStyleBand.OutlookGroupBy;
			resources.ApplyResources(this.ultraGridRule, "ultraGridRule");
			this.ultraGridRule.Name = "ultraGridRule";
			this.ultraGridRule.AfterHeaderCheckStateChanged += new Infragistics.Win.UltraWinGrid.AfterHeaderCheckStateChangedEventHandler(ultraGridRule_AfterHeaderCheckStateChanged);
			this.ultraGridRule.AfterCellUpdate += new Infragistics.Win.UltraWinGrid.CellEventHandler(ultraGridRule_AfterCellUpdate);
			this.ultraGridRule.MouseClick += new System.Windows.Forms.MouseEventHandler(ultraGridRule_MouseClick);
			this.ultraGridRule.InitializeLayout += new Infragistics.Win.UltraWinGrid.InitializeLayoutEventHandler(ultraGridRule_InitializeLayout);
			this.ultraGridRule.DoubleClickCell += new Infragistics.Win.UltraWinGrid.DoubleClickCellEventHandler(ultraGridRule_DoubleClickCell);
			this.ultraGridRule.AfterSelectChange += new Infragistics.Win.UltraWinGrid.AfterSelectChangeEventHandler(ultraGridRule_AfterSelectChange);
			this.panel1.Controls.Add(this.btExpression);
			this.panel1.Controls.Add(this.btDeleteCondition);
			this.panel1.Controls.Add(this.btAddCondition);
			this.panel1.Controls.Add(this.btDeleteRule);
			this.panel1.Controls.Add(this.btAddRule);
			resources.ApplyResources(this.panel1, "panel1");
			this.panel1.Name = "panel1";
			resources.ApplyResources(this.btExpression, "btExpression");
			this.btExpression.Name = "btExpression";
			this.btExpression.UseVisualStyleBackColor = true;
			this.btExpression.Click += new System.EventHandler(btExpression_Click);
			resources.ApplyResources(this.btDeleteCondition, "btDeleteCondition");
			this.btDeleteCondition.Name = "btDeleteCondition";
			this.btDeleteCondition.UseVisualStyleBackColor = true;
			this.btDeleteCondition.Click += new System.EventHandler(btDeleteCondition_Click);
			resources.ApplyResources(this.btAddCondition, "btAddCondition");
			this.btAddCondition.Name = "btAddCondition";
			this.btAddCondition.UseVisualStyleBackColor = true;
			this.btAddCondition.Click += new System.EventHandler(btAddCondition_Click);
			resources.ApplyResources(this.btDeleteRule, "btDeleteRule");
			this.btDeleteRule.Name = "btDeleteRule";
			this.btDeleteRule.UseVisualStyleBackColor = true;
			this.btDeleteRule.Click += new System.EventHandler(btDeleteRule_Click);
			resources.ApplyResources(this.btAddRule, "btAddRule");
			this.btAddRule.Name = "btAddRule";
			this.btAddRule.UseVisualStyleBackColor = true;
			this.btAddRule.Click += new System.EventHandler(btAddRule_Click);
			resources.ApplyResources(this, "$this");
			base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			base.Controls.Add(this.Rulepanel);
			base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
			base.MaximizeBox = false;
			base.MinimizeBox = false;
			base.Name = "Rule_Editor";
			base.ShowIcon = false;
			base.ShowInTaskbar = false;
			this.Rulepanel.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)this.ultraGridRule).EndInit();
			this.panel1.ResumeLayout(false);
			base.ResumeLayout(false);
		}

		public Rule_Editor(IApplication app, IRuleItem mRuleItem, bool isLocked)
		{
			InitializeComponent();
			m_LCheck = 0;
			m_LPattern = 0;
			m_LTarget = 0;
			m_LOperator = 0;
			m_LValue = "0";
			m_LExpressionCheck = -1;
			mApplication = app;
			m_LListCopyCondition = new List<IConditionEditor>();
			m_LListCopyIntepretation = new List<string>();
			m_LListCopyItem = new List<string>();
			mResourceManager = ResourceManager.CreateFileBasedResourceManager("ExperimentRuleEditor", mApplication.GetResourceFolder() + GetType().Namespace + "\\", null);
			m_LRuleItem = mRuleItem;
			InitializeForm(isLocked);
			panel1.Visible = !isLocked;
			m_LLocked = isLocked;
			mApplication = app;
			mPcrLogService = (IPcrLogService)app.GetService("PcrLogService");
			mConfigurationService = (IConfigurationService)app.GetService("ConfigurationService");
		}

		private void InitializeForm(bool isLocked)
		{
			UltraDataSource ultraDataSource = new UltraDataSource();
			ultraDataSource.Band.Columns.Add("Item");
			ultraDataSource.Band.Columns.Add("Property");
			ultraDataSource.Band.Columns.Add("Condition1", typeof(string));
			ultraDataSource.Band.Columns.Add("Connect1", typeof(string));
			ultraDataSource.Band.Columns.Add("Condition2", typeof(string));
			ultraDataSource.Band.Columns.Add("Connect2", typeof(string));
			ultraDataSource.Band.Columns.Add("Condition3", typeof(string));
			ultraDataSource.Band.Columns.Add("Connect3", typeof(string));
			ultraDataSource.Band.Columns.Add("Condition4", typeof(string));
			ultraDataSource.Band.Columns.Add("Interpretation");
			ultraDataSource.Band.Columns.Add("Target");
			ultraDataSource.Band.Columns.Add("Color");
			((ISupportInitialize)ultraGridRule).BeginInit();
			UltraGridBand ultraGridBand = new UltraGridBand("Band 0", -1);
			foreach (UltraDataColumn item in (IEnumerable)ultraDataSource.Band.Columns)
			{
				UltraGridColumn ultraGridColumn = new UltraGridColumn(item.Key);
				if (item.Key.Contains("Connect") && ultraGridColumn.Header.Caption != "")
				{
					ultraGridColumn.Header.Caption = " ";
				}
				ultraGridColumn.Header.FixedHeaderIndicator = FixedHeaderIndicator.None;
				ultraGridColumn.Header.Appearance.TextHAlign = HAlign.Center;
				ultraGridColumn.AutoSizeMode = ColumnAutoSizeMode.AllRowsInBand;
				ultraGridColumn.CellActivation = Activation.NoEdit;
				ultraGridBand.Columns.Add(ultraGridColumn);
			}
			ultraGridBand.Columns["Item"].Header.Caption = mResourceManager.GetString("ItemString");
			ultraGridBand.Columns["Property"].Header.Caption = mResourceManager.GetString("PropertyString");
			ultraGridBand.Columns["Condition1"].Header.Caption = mResourceManager.GetString("ConditionString") + "1";
			ultraGridBand.Columns["Condition2"].Header.Caption = mResourceManager.GetString("ConditionString") + "2";
			ultraGridBand.Columns["Condition3"].Header.Caption = mResourceManager.GetString("ConditionString") + "3";
			ultraGridBand.Columns["Condition4"].Header.Caption = mResourceManager.GetString("ConditionString") + "4";
			ultraGridBand.Columns["Interpretation"].Header.Caption = mResourceManager.GetString("ConclusionString");
			ultraGridBand.Columns["Target"].Header.Caption = mResourceManager.GetString("TargetLocationString");
			ultraGridBand.Columns["Color"].Header.Caption = mResourceManager.GetString("ColorString");
			ultraGridRule.DisplayLayout.BandsSerializer.Add(ultraGridBand);
			ultraGridRule.DataSource = ultraDataSource;
			ultraGridRule.UpdateMode = UpdateMode.OnUpdate;
			((ISupportInitialize)ultraGridRule).EndInit();
			btDeleteCondition.Enabled = false;
			foreach (UltraGridColumn column in ultraGridBand.Columns)
			{
				column.PerformAutoResize(PerformAutoSizeType.AllRowsInBand);
				column.Width += 24;
			}
		}

		private void ultraGridRule_InitializeLayout(object sender, InitializeLayoutEventArgs e)
		{
			try
			{
				e.Layout.Override.CellClickAction = CellClickAction.EditAndSelectText;
				e.Layout.Override.CellAppearance.BackColor = Color.White;
				e.Layout.Override.AllowMultiCellOperations = AllowMultiCellOperation.All;
				e.Layout.Override.RowSizing = RowSizing.AutoFixed;
				e.Layout.ViewStyleBand = ViewStyleBand.Horizontal;
				e.Layout.Override.RowSelectors = DefaultableBoolean.True;
				e.Layout.Override.RowSelectorHeaderStyle = RowSelectorHeaderStyle.SeparateElement;
				e.Layout.Override.RowSelectorNumberStyle = RowSelectorNumberStyle.VisibleIndex;
				e.Layout.Override.RowSelectorStyle = HeaderStyle.Standard;
				e.Layout.Override.RowSelectorAppearance.TextHAlign = HAlign.Center;
				e.Layout.Override.RowSelectorAppearance.TextVAlign = VAlign.Middle;
				e.Layout.Override.RowSelectorAppearance.ImageAlpha = Alpha.Transparent;
				e.Layout.Override.ExpansionIndicator = ShowExpansionIndicator.Never;
				e.Layout.CaptionVisible = DefaultableBoolean.False;
				e.Layout.Override.ColumnAutoSizeMode = ColumnAutoSizeMode.AllRowsInBand;
				e.Layout.Override.AllowColMoving = AllowColMoving.NotAllowed;
				e.Layout.Override.AllowColSizing = AllowColSizing.None;
				e.Layout.Scrollbars = Scrollbars.Both;
				e.Layout.ScrollStyle = ScrollStyle.Immediate;
				e.Layout.Override.RowSizing = RowSizing.AutoFixed;
				e.Layout.Override.ColumnAutoSizeMode = ColumnAutoSizeMode.AllRowsInBand;
				e.Layout.Override.FilterClearButtonLocation = FilterClearButtonLocation.Row;
				e.Layout.Override.FilterOperandStyle = FilterOperandStyle.DropDownList;
				e.Layout.Override.FilterOperatorDropDownItems = FilterOperatorDropDownItems.Equals;
				e.Layout.Override.FilterOperatorDefaultValue = FilterOperatorDefaultValue.Equals;
				e.Layout.Override.FilterOperatorLocation = FilterOperatorLocation.Hidden;
				e.Layout.Override.RowFilterMode = RowFilterMode.SiblingRowsOnly;
				e.Layout.Override.SequenceFilterRow = 0;
				e.Layout.Override.SelectTypeCell = SelectType.Extended;
				e.Layout.Override.SelectTypeCol = SelectType.Extended;
				e.Layout.Override.SelectTypeRow = SelectType.Extended;
				e.Layout.UseFixedHeaders = true;
				e.Layout.Override.FixedHeaderIndicator = FixedHeaderIndicator.None;
				foreach (UltraGridColumn column in e.Layout.Bands[0].Columns)
				{
					column.PerformAutoResize(PerformAutoSizeType.AllRowsInBand);
					column.Width += 24;
				}
			}
			catch (Exception ex)
			{
				mPcrLogService.ShowExceptionDialogBox(ex);
			}
		}

		private void ultraGridRule_AfterCellUpdate(object sender, CellEventArgs e)
		{
			UltraGrid ultraGrid = (UltraGrid)sender;
			ultraGrid.EventManager.SetEnabled(GridEventIds.AfterCellUpdate, false);
			try
			{
				foreach (UltraGridRow row in ultraGridRule.Rows)
				{
					if (row.Cells[0].Text == mConfigurationService.GetDetectionTypeArray(PcrSystemType.AbsoluteAnalysis)[1])
					{
						row.Cells[1].Activation = Activation.NoEdit;
					}
					else
					{
						row.Cells[1].Activation = Activation.AllowEdit;
					}
				}
			}
			catch (Exception ex)
			{
				mPcrLogService.ShowExceptionDialogBox(ex);
			}
			finally
			{
				ultraGrid.EventManager.SetEnabled(GridEventIds.AfterCellUpdate, true);
			}
		}

		private void ultraGridRule_DoubleClickCell(object sender, DoubleClickCellEventArgs e)
		{
			if (!m_LLocked)
			{
				RuleConditionEdit(e.Cell);
				if (e.Cell.Column.Key == "Color" && m_LColorFlag)
				{
					PopColorDialog(e.Cell);
				}
			}
		}

		public bool SaveRuleGrid(UltraGrid multraGridRule, IRuleItem mRuleItem)
		{
			List<IRuleEditor> list = new List<IRuleEditor>();
			foreach (UltraGridRow row in multraGridRule.Rows)
			{
				IRuleEditor ruleEditor = null;
				ruleEditor = new RuleEditor();
				ruleEditor.RuleItemName = row.Cells[0].Text;
				ruleEditor.RuleProperty = row.Cells[1].Text;
				ruleEditor.RuleInterpretation = row.Cells[row.Cells.Count - 3].Text;
				if (m_LTargetFlag)
				{
					ruleEditor.RuleTarget = row.Cells[row.Cells.Count - 2].Text;
				}
				if (m_LColorFlag)
				{
					ruleEditor.RuleColorName = row.Cells[row.Cells.Count - 1].Tag.ToString();
				}
				if (ruleEditor.RuleInterpretation != "")
				{
					List<IConditionEditor> list2 = new List<IConditionEditor>();
					if (row.Cells.Count > 5)
					{
						for (int i = 0; i < row.Cells.Count - 5; i += 2)
						{
							IConditionEditor conditionEditor = new ConditionEditor();
							if (!row.Cells[i + 2].Column.Hidden)
							{
								conditionEditor.Condition = row.Cells[i + 2].Text;
								conditionEditor.ConditionIndex = i + 2;
								if (row.Cells[i + 2].Text == "")
								{
									conditionEditor.ExpressionIndex = 0;
								}
								else
								{
									conditionEditor.ExpressionIndex = (int)row.Cells[i + 2].Tag;
								}
							}
							if (row.Cells[i + 3].Column.Header.Caption.Contains(" ") && !row.Cells[i + 3].Column.Hidden)
							{
								conditionEditor.Connection = row.Cells[i + 3].Text;
								conditionEditor.ConnectionIndex = i + 3;
							}
							if (conditionEditor.Condition != null || conditionEditor.Connection != null)
							{
								list2.Add(conditionEditor);
							}
						}
					}
					ruleEditor.ConditionEditorList = list2;
					list.Add(ruleEditor);
					continue;
				}
				MessageBox.Show(mResourceManager.GetString("InterpretationNotBlankString"), mResourceManager.GetString("ErrorString"));
				return false;
			}
			mRuleItem.RuleEditorList = list;
			mRuleItem.ExpressionEditorList = m_LRuleItem.ExpressionEditorList;
			mRuleItem.SelectTarget = m_LTargetFlag;
			mRuleItem.SelectColor = m_LColorFlag;
			return true;
		}

		private void btAddRule_Click(object sender, EventArgs e)
		{
			try
			{
				UltraGridRow ultraGridRow = ultraGridRule.DisplayLayout.Bands[0].AddNew();
				if (!btDeleteRule.Enabled)
				{
					btDeleteRule.Enabled = true;
				}
				foreach (UltraGridCell cell in ultraGridRow.Cells)
				{
					if (cell.Column.Header.Caption.Contains(" "))
					{
						cell.Value = "AND";
						cell.Appearance.TextVAlign = VAlign.Middle;
						cell.Appearance.TextHAlign = HAlign.Center;
					}
					if (cell.Column.Header.Caption.Contains(mResourceManager.GetString("ItemString")))
					{
						cell.Value = mConfigurationService.GetDetectionTypeArray(PcrSystemType.AbsoluteAnalysis)[1];
						cell.Appearance.TextVAlign = VAlign.Middle;
						cell.Appearance.TextHAlign = HAlign.Center;
					}
					if (cell.Column.Key.Contains("Color"))
					{
						if (!m_LColorFlag)
						{
							object tag = Color.White.ToArgb();
							cell.Tag = tag;
							cell.Appearance.BackColor = Color.White;
							cell.Appearance.ForeColor = Color.White;
							cell.ActiveAppearance.BackColor = Color.White;
							cell.ActiveAppearance.ForeColor = Color.White;
						}
						else
						{
							object tag2 = Color.Black.ToArgb();
							cell.Tag = tag2;
							cell.Appearance.BackColor = Color.Black;
							cell.Appearance.ForeColor = Color.Black;
							cell.ActiveAppearance.BackColor = Color.Black;
							cell.ActiveAppearance.ForeColor = Color.Black;
						}
					}
					if (!(cell.Column.Key == "Target") || m_LProjectName == null)
					{
						continue;
					}
					string[] array = m_LProjectName.Split(new string[1] { "," }, StringSplitOptions.None);
					if (array == null)
					{
						continue;
					}
					ValueList valueList = new ValueList();
					for (int i = 0; i < array.Length; i++)
					{
						if (array[i] != "N/A" && array[i] != "")
						{
							valueList.ValueListItems.Add(i + 1, array[i]);
						}
					}
					valueList.ValueListItems.Add(array.Length + 1, " ");
					cell.Column.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
					cell.Column.ValueList = valueList;
				}
				foreach (UltraGridColumn column in ultraGridRule.DisplayLayout.Bands[0].Columns)
				{
					column.PerformAutoResize(PerformAutoSizeType.AllRowsInBand);
					column.Width += 24;
				}
				btDeleteRule.Enabled = true;
			}
			catch (Exception ex)
			{
				mPcrLogService.ShowExceptionDialogBox(ex);
			}
		}

		private void btDeleteRule_Click(object sender, EventArgs e)
		{
			try
			{
				if (ultraGridRule.Selected.Rows.Count > 0)
				{
					ultraGridRule.DeleteSelectedRows(false);
					if (ultraGridRule.Rows.Count == 0)
					{
						btDeleteRule.Enabled = false;
					}
				}
				else if (ultraGridRule.Rows.Count - 1 >= 0)
				{
					ultraGridRule.Rows[ultraGridRule.Rows.Count - 1].Delete(false);
					if (ultraGridRule.Rows.Count == 0)
					{
						btDeleteRule.Enabled = false;
					}
				}
				foreach (UltraGridColumn column in ultraGridRule.DisplayLayout.Bands[0].Columns)
				{
					column.PerformAutoResize(PerformAutoSizeType.AllRowsInBand);
					column.Width += 24;
				}
			}
			catch (Exception ex)
			{
				mPcrLogService.ShowExceptionDialogBox(ex);
			}
		}

		private void btAddCondition_Click(object sender, EventArgs e)
		{
			try
			{
				ultraGridRule.Selected.Columns.Clear();
				bool flag = false;
				bool flag2 = false;
				for (int i = 0; i < ultraGridRule.DisplayLayout.Bands[0].Columns.Count; i++)
				{
					if (ultraGridRule.DisplayLayout.Bands[0].Columns[i].Header.Caption.Contains(mResourceManager.GetString("ConditionString")) && !ultraGridRule.DisplayLayout.Bands[0].Columns[i].Hidden)
					{
						flag2 = true;
						break;
					}
				}
				for (int j = 0; j < ultraGridRule.DisplayLayout.Bands[0].Columns.Count; j++)
				{
					if (!ultraGridRule.DisplayLayout.Bands[0].Columns[j].Header.Caption.Contains(mResourceManager.GetString("ConditionString")) || !ultraGridRule.DisplayLayout.Bands[0].Columns[j].Hidden)
					{
						continue;
					}
					ultraGridRule.DisplayLayout.Bands[0].Columns[j].Hidden = false;
					if (!flag2)
					{
						flag = true;
						break;
					}
					if (ultraGridRule.DisplayLayout.Bands[0].Columns[j - 1].Key == "Property")
					{
						flag = false;
						if (!ultraGridRule.DisplayLayout.Bands[0].Columns[j + 1].Header.Caption.Contains(" ") || !ultraGridRule.DisplayLayout.Bands[0].Columns[j + 1].Hidden)
						{
							continue;
						}
						ultraGridRule.DisplayLayout.Bands[0].Columns[j + 1].Hidden = false;
						ValueList valueList = new ValueList();
						valueList.ValueListItems.Add(1, "AND");
						valueList.ValueListItems.Add(2, "OR");
						valueList.ValueListItems.Add(3, " ");
						ultraGridRule.DisplayLayout.Bands[0].Columns[j + 1].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
						ultraGridRule.DisplayLayout.Bands[0].Columns[j + 1].Header.Caption = " ";
						ultraGridRule.DisplayLayout.Bands[0].Columns[j + 1].ValueList = valueList;
						foreach (UltraGridRow row in ultraGridRule.Rows)
						{
							row.Cells[j + 1].Value = "AND";
							row.Cells[j + 1].Appearance.TextVAlign = VAlign.Middle;
							row.Cells[j + 1].Appearance.TextHAlign = HAlign.Center;
						}
						flag = true;
						break;
					}
					flag = false;
					if (ultraGridRule.DisplayLayout.Bands[0].Columns[j - 1].Header.Caption.Contains(" ") && ultraGridRule.DisplayLayout.Bands[0].Columns[j - 1].Hidden)
					{
						ultraGridRule.DisplayLayout.Bands[0].Columns[j - 1].Hidden = false;
						ValueList valueList2 = new ValueList();
						valueList2.ValueListItems.Add(1, "AND");
						valueList2.ValueListItems.Add(2, "OR");
						valueList2.ValueListItems.Add(3, " ");
						ultraGridRule.DisplayLayout.Bands[0].Columns[j - 1].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
						ultraGridRule.DisplayLayout.Bands[0].Columns[j - 1].Header.Caption = " ";
						ultraGridRule.DisplayLayout.Bands[0].Columns[j - 1].ValueList = valueList2;
						foreach (UltraGridRow row2 in ultraGridRule.Rows)
						{
							row2.Cells[j - 1].Value = "AND";
							row2.Cells[j - 1].Appearance.TextVAlign = VAlign.Middle;
							row2.Cells[j - 1].Appearance.TextHAlign = HAlign.Center;
						}
						flag = true;
						break;
					}
					if (!ultraGridRule.DisplayLayout.Bands[0].Columns[j + 1].Header.Caption.Contains(" ") || !ultraGridRule.DisplayLayout.Bands[0].Columns[j + 1].Hidden)
					{
						continue;
					}
					ultraGridRule.DisplayLayout.Bands[0].Columns[j + 1].Hidden = false;
					ValueList valueList3 = new ValueList();
					valueList3.ValueListItems.Add(1, "AND");
					valueList3.ValueListItems.Add(2, "OR");
					valueList3.ValueListItems.Add(3, " ");
					ultraGridRule.DisplayLayout.Bands[0].Columns[j + 1].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
					ultraGridRule.DisplayLayout.Bands[0].Columns[j + 1].Header.Caption = " ";
					ultraGridRule.DisplayLayout.Bands[0].Columns[j + 1].ValueList = valueList3;
					foreach (UltraGridRow row3 in ultraGridRule.Rows)
					{
						row3.Cells[j + 1].Value = "AND";
						row3.Cells[j + 1].Appearance.TextVAlign = VAlign.Middle;
						row3.Cells[j + 1].Appearance.TextHAlign = HAlign.Center;
					}
					flag = true;
					break;
				}
				if (!flag)
				{
					if (ultraGridRule.DisplayLayout.Bands[0].Columns[ultraGridRule.DisplayLayout.Bands[0].Columns.Count - 4].Header.Caption.Contains(mResourceManager.GetString("ConditionString")))
					{
						string s = ultraGridRule.DisplayLayout.Bands[0].Columns[ultraGridRule.DisplayLayout.Bands[0].Columns.Count - 4].Header.Caption.Replace(mResourceManager.GetString("ConditionString"), "");
						int num = int.Parse(s) + 1;
						string key = "Connect" + num;
						ultraGridRule.DisplayLayout.Bands[0].Columns.Insert(ultraGridRule.DisplayLayout.Bands[0].Columns.Count - 3, key);
						ultraGridRule.DisplayLayout.Bands[0].Columns[key].Header.Caption = " ";
						ValueList valueList4 = new ValueList();
						valueList4.ValueListItems.Add(1, "AND");
						valueList4.ValueListItems.Add(2, "OR");
						valueList4.ValueListItems.Add(3, " ");
						ultraGridRule.DisplayLayout.Bands[0].Columns[key].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
						ultraGridRule.DisplayLayout.Bands[0].Columns[key].Header.Caption = " ";
						ultraGridRule.DisplayLayout.Bands[0].Columns[key].ValueList = valueList4;
						foreach (UltraGridRow row4 in ultraGridRule.Rows)
						{
							row4.Cells[key].Value = "AND";
							row4.Cells[key].Appearance.TextVAlign = VAlign.Middle;
							row4.Cells[key].Appearance.TextHAlign = HAlign.Center;
						}
						string key2 = "Condition" + num;
						ultraGridRule.DisplayLayout.Bands[0].Columns.Insert(ultraGridRule.DisplayLayout.Bands[0].Columns.Count - 3, key2);
						ultraGridRule.DisplayLayout.Bands[0].Columns[key2].Header.Caption = mResourceManager.GetString("ConditionString") + num;
						ultraGridRule.DisplayLayout.Bands[0].Columns[key2].Header.Appearance.TextHAlign = HAlign.Center;
						ultraGridRule.DisplayLayout.Bands[0].Columns[key2].Header.VisiblePosition = ultraGridRule.DisplayLayout.Bands[0].Columns.Count - 4;
						ultraGridRule.DisplayLayout.Bands[0].Columns[key2].CellActivation = Activation.NoEdit;
					}
					else
					{
						string key3 = "Condition1";
						ultraGridRule.DisplayLayout.Bands[0].Columns.Insert(ultraGridRule.DisplayLayout.Bands[0].Columns.Count - 3, key3);
						ultraGridRule.DisplayLayout.Bands[0].Columns[key3].Header.Caption = mResourceManager.GetString("ConditionString") + "1";
						ultraGridRule.DisplayLayout.Bands[0].Columns[key3].Header.Appearance.TextHAlign = HAlign.Center;
						ultraGridRule.DisplayLayout.Bands[0].Columns[key3].Header.VisiblePosition = ultraGridRule.DisplayLayout.Bands[0].Columns.Count - 4;
						ultraGridRule.DisplayLayout.Bands[0].Columns[key3].CellActivation = Activation.NoEdit;
					}
				}
				foreach (UltraGridColumn column in ultraGridRule.DisplayLayout.Bands[0].Columns)
				{
					column.PerformAutoResize(PerformAutoSizeType.AllRowsInBand);
					column.Width += 24;
				}
			}
			catch (Exception ex)
			{
				mPcrLogService.ShowExceptionDialogBox(ex);
			}
		}

		private void btDeleteCondition_Click(object sender, EventArgs e)
		{
			try
			{
				bool flag = false;
				for (int i = 0; i < m_LListSelectCondition.Count; i++)
				{
					for (int j = 0; j < ultraGridRule.DisplayLayout.Bands[0].Columns.Count; j++)
					{
						if (!(ultraGridRule.DisplayLayout.Bands[0].Columns[j].Key == m_LListSelectCondition[i]))
						{
							continue;
						}
						ultraGridRule.DisplayLayout.Bands[0].Columns[j].Hidden = true;
						foreach (UltraGridRow row in ultraGridRule.Rows)
						{
							row.Cells[j].Value = null;
						}
						for (int num = j; num > 1; num--)
						{
							if (!ultraGridRule.DisplayLayout.Bands[0].Columns[num - 1].Hidden)
							{
								flag = false;
								if (ultraGridRule.DisplayLayout.Bands[0].Columns[num - 1].Key == "Property")
								{
									if (ultraGridRule.DisplayLayout.Bands[0].Columns[j + 1].Header.Caption.Contains(" ") && !ultraGridRule.DisplayLayout.Bands[0].Columns[j + 1].Hidden)
									{
										ultraGridRule.DisplayLayout.Bands[0].Columns[j + 1].Hidden = true;
										foreach (UltraGridRow row2 in ultraGridRule.Rows)
										{
											row2.Cells[j + 1].Value = null;
										}
										flag = true;
										break;
									}
								}
								else if (ultraGridRule.DisplayLayout.Bands[0].Columns[j - 1].Header.Caption.Contains(" ") && !ultraGridRule.DisplayLayout.Bands[0].Columns[j - 1].Hidden)
								{
									ultraGridRule.DisplayLayout.Bands[0].Columns[j - 1].Hidden = true;
									foreach (UltraGridRow row3 in ultraGridRule.Rows)
									{
										row3.Cells[j - 1].Value = null;
									}
									flag = true;
									break;
								}
							}
						}
						if (flag || !ultraGridRule.DisplayLayout.Bands[0].Columns[j - 1].Header.Caption.Contains(" ") || ultraGridRule.DisplayLayout.Bands[0].Columns[j - 1].Hidden)
						{
							continue;
						}
						ultraGridRule.DisplayLayout.Bands[0].Columns[j - 1].Hidden = true;
						foreach (UltraGridRow row4 in ultraGridRule.Rows)
						{
							row4.Cells[j - 1].Value = null;
						}
						break;
					}
				}
				btDeleteCondition.Enabled = false;
			}
			catch (Exception ex)
			{
				mPcrLogService.ShowExceptionDialogBox(ex);
			}
		}

		public bool RefreshRuleGrid(IApplication app, UltraGrid multraGridRule, IPcrExperimentProject mPcrExperimentProject)
		{
			m_LPcrExperimentProject = mPcrExperimentProject;
			if (mPcrExperimentProject != null)
			{
				m_LRuleItem = mPcrExperimentProject.AdvancedRule;
				if (multraGridRule == null)
				{
					ultraGridRule = new UltraGrid();
				}
				else
				{
					ultraGridRule = multraGridRule;
				}
				ultraGridRule.DataSource = null;
				m_LProjectName = null;
				m_LTargetFlag = m_LRuleItem.SelectTarget;
				m_LColorFlag = m_LRuleItem.SelectColor;
				GetProjectName();
				RefreshDataSource();
				InitializeGridMenu();
				for (int i = 0; i < ultraGridRule.Rows.Count; i++)
				{
					if (ultraGridRule.Rows[i].Cells.Count > 5)
					{
						int num = 0;
						for (int j = 0; j < ultraGridRule.Rows[i].Cells.Count - 5; j += 2)
						{
							if (ultraGridRule.Rows[i].Cells[j + 2].Text == "")
							{
								num++;
								continue;
							}
							ultraGridRule.Rows[i].Cells[j + 2].Tag = m_LRuleItem.RuleEditorList[i].ConditionEditorList[num].ExpressionIndex;
							ultraGridRule.Rows[i].Cells[j + 2].Appearance.TextHAlign = HAlign.Center;
							num++;
						}
						int result;
						if (int.TryParse(ultraGridRule.Rows[i].Cells["Color"].Text, out result))
						{
							ultraGridRule.Rows[i].Cells["Color"].Tag = result;
							ultraGridRule.Rows[i].Cells["Color"].Appearance.BackColor = Color.FromArgb(result);
							ultraGridRule.Rows[i].Cells["Color"].Appearance.ForeColor = Color.FromArgb(result);
							ultraGridRule.Rows[i].Cells["Color"].ActiveAppearance.BackColor = Color.FromArgb(result);
							ultraGridRule.Rows[i].Cells["Color"].ActiveAppearance.ForeColor = Color.FromArgb(result);
							ultraGridRule.Rows[i].Cells["Color"].Value = null;
						}
						else if (m_LColorFlag)
						{
							ultraGridRule.Rows[i].Cells["Color"].Tag = Color.Black.ToArgb();
							ultraGridRule.Rows[i].Cells["Color"].Appearance.BackColor = Color.Black;
							ultraGridRule.Rows[i].Cells["Color"].Appearance.ForeColor = Color.Black;
							ultraGridRule.Rows[i].Cells["Color"].ActiveAppearance.BackColor = Color.Black;
							ultraGridRule.Rows[i].Cells["Color"].ActiveAppearance.ForeColor = Color.Black;
							ultraGridRule.Rows[i].Cells["Color"].Value = null;
						}
						else
						{
							ultraGridRule.Rows[i].Cells["Color"].Tag = Color.White.ToArgb();
							ultraGridRule.Rows[i].Cells["Color"].Appearance.BackColor = Color.White;
							ultraGridRule.Rows[i].Cells["Color"].Appearance.ForeColor = Color.White;
							ultraGridRule.Rows[i].Cells["Color"].ActiveAppearance.BackColor = Color.White;
							ultraGridRule.Rows[i].Cells["Color"].ActiveAppearance.ForeColor = Color.White;
							ultraGridRule.Rows[i].Cells["Color"].Value = null;
						}
						ultraGridRule.Rows[i].CellAppearance.TextHAlign = HAlign.Center;
					}
					else
					{
						int result2;
						if (int.TryParse(ultraGridRule.Rows[i].Cells["Color"].Text, out result2))
						{
							ultraGridRule.Rows[i].Cells["Color"].Tag = result2;
							ultraGridRule.Rows[i].Cells["Color"].Appearance.BackColor = Color.FromArgb(result2);
							ultraGridRule.Rows[i].Cells["Color"].Appearance.ForeColor = Color.FromArgb(result2);
							ultraGridRule.Rows[i].Cells["Color"].ActiveAppearance.BackColor = Color.FromArgb(result2);
							ultraGridRule.Rows[i].Cells["Color"].ActiveAppearance.ForeColor = Color.FromArgb(result2);
							ultraGridRule.Rows[i].Cells["Color"].Value = null;
						}
						else if (m_LColorFlag)
						{
							ultraGridRule.Rows[i].Cells["Color"].Tag = Color.Black.ToArgb();
							ultraGridRule.Rows[i].Cells["Color"].Appearance.BackColor = Color.Black;
							ultraGridRule.Rows[i].Cells["Color"].Appearance.ForeColor = Color.Black;
							ultraGridRule.Rows[i].Cells["Color"].ActiveAppearance.BackColor = Color.Black;
							ultraGridRule.Rows[i].Cells["Color"].ActiveAppearance.ForeColor = Color.Black;
							ultraGridRule.Rows[i].Cells["Color"].Value = null;
						}
						else
						{
							ultraGridRule.Rows[i].Cells["Color"].Tag = Color.White.ToArgb();
							ultraGridRule.Rows[i].Cells["Color"].Appearance.BackColor = Color.White;
							ultraGridRule.Rows[i].Cells["Color"].Appearance.ForeColor = Color.White;
							ultraGridRule.Rows[i].Cells["Color"].ActiveAppearance.BackColor = Color.White;
							ultraGridRule.Rows[i].Cells["Color"].ActiveAppearance.ForeColor = Color.White;
							ultraGridRule.Rows[i].Cells["Color"].Value = null;
						}
						ultraGridRule.Rows[i].CellAppearance.TextHAlign = HAlign.Center;
					}
				}
				if (mConfigurationService != null)
				{
					m_LProjectType = mConfigurationService.GetDetectionTypeArray(PcrSystemType.AbsoluteAnalysis);
					ultraGridRule.DisplayLayout.Bands[0].Columns["Property"].CellActivation = Activation.AllowEdit;
					ultraGridRule.DisplayLayout.Bands[0].Columns["Item"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
					ultraGridRule.DisplayLayout.Bands[0].Columns["Item"].CellActivation = Activation.AllowEdit;
					ultraGridRule.DisplayLayout.Bands[0].Columns["Item"].ValueList = null;
					ValueList valueList = new ValueList();
					if (m_LProjectType != null)
					{
						for (int k = 0; k < m_LProjectType.Length; k++)
						{
							valueList.ValueListItems.Add(k, m_LProjectType[k]);
						}
						valueList.ValueListItems.Add(m_LProjectType.Length, " ");
						ultraGridRule.DisplayLayout.Bands[0].Columns["Item"].ValueList = valueList;
					}
					if (m_LProjectName != null)
					{
						string[] array = m_LProjectName.Split(new string[1] { "," }, StringSplitOptions.None);
						if (array != null)
						{
							ValueList valueList2 = new ValueList();
							for (int l = 0; l < array.Length; l++)
							{
								if (array[l] != "N/A" && array[l] != "")
								{
									object dataValue = array[l];
									valueList2.ValueListItems.Add(dataValue, array[l]);
								}
							}
							valueList2.ValueListItems.Add(string.Empty, " ");
							ultraGridRule.DisplayLayout.Bands[0].Columns["Target"].ValueList = valueList2;
						}
					}
					ultraGridRule.DisplayLayout.Bands[0].Columns["Color"].CellActivation = Activation.NoEdit;
				}
				if (ultraGridRule.Rows.Count == 0)
				{
					btDeleteRule.Enabled = false;
				}
				btDeleteCondition.Enabled = false;
				foreach (UltraGridColumn column in ultraGridRule.DisplayLayout.Bands[0].Columns)
				{
					if (m_LLocked)
					{
						column.CellActivation = Activation.NoEdit;
					}
				}
				return true;
			}
			foreach (UltraGridColumn column2 in ultraGridRule.DisplayLayout.Bands[0].Columns)
			{
				if (m_LLocked)
				{
					column2.CellActivation = Activation.NoEdit;
				}
			}
			return false;
		}

		private void ultraGridRule_AfterSelectChange(object sender, AfterSelectChangeEventArgs e)
		{
			try
			{
				if (typeof(Infragistics.Win.UltraWinGrid.ColumnHeader) != e.Type)
				{
					return;
				}
				m_LListSelectCondition = new List<string>();
				for (int i = 0; i < ultraGridRule.Selected.Columns.Count; i++)
				{
					for (int j = 0; j < ultraGridRule.DisplayLayout.Bands[0].Columns.Count; j++)
					{
						if (ultraGridRule.DisplayLayout.Bands[0].Columns[j].Key == ultraGridRule.Selected.Columns[i].Column.Key && ultraGridRule.DisplayLayout.Bands[0].Columns[j].Header.Caption.Contains(mResourceManager.GetString("ConditionString")))
						{
							btDeleteCondition.Enabled = true;
							m_LListSelectCondition.Add(ultraGridRule.Selected.Columns[i].Column.Key);
						}
					}
				}
			}
			catch (Exception ex)
			{
				mPcrLogService.ShowExceptionDialogBox(ex);
			}
		}

		private void RefreshDataSource()
		{
			UltraDataSource ultraDataSource = new UltraDataSource();
			ultraDataSource.Band.Columns.Add("Item");
			ultraDataSource.Band.Columns.Add("Property");
			int num = 0;
			int num2 = 0;
			IRuleEditor ruleEditor = null;
			m_LConditionNum = 0;
			if (m_LRuleItem.RuleEditorList != null)
			{
				if (m_LRuleItem.RuleEditorList.Count > 0)
				{
					foreach (IRuleEditor ruleEditor2 in m_LRuleItem.RuleEditorList)
					{
						foreach (IConditionEditor conditionEditor in ruleEditor2.ConditionEditorList)
						{
							if (num < conditionEditor.ConditionIndex)
							{
								ruleEditor = ruleEditor2;
								num = conditionEditor.ConditionIndex;
							}
						}
					}
					if (num > 1)
					{
						int num3 = 0;
						int num4 = 0;
						foreach (IConditionEditor conditionEditor2 in ruleEditor.ConditionEditorList)
						{
							if (conditionEditor2.Condition != null)
							{
								num3++;
								string columnKey = "Condition" + num3;
								m_LConditionNum++;
								ultraDataSource.Band.Columns.Add(columnKey);
								if (conditionEditor2.ConditionIndex == num)
								{
									break;
								}
							}
							if (conditionEditor2.Connection != null)
							{
								num4++;
								string columnKey2 = "Connect" + num3;
								ultraDataSource.Band.Columns.Add(columnKey2);
							}
						}
						num2 = num3 + num4;
					}
				}
				else
				{
					ultraDataSource.Band.Columns.Add("Condition1");
					ultraDataSource.Band.Columns.Add("Connect1");
					ultraDataSource.Band.Columns.Add("Condition2");
					ultraDataSource.Band.Columns.Add("Connect2");
					ultraDataSource.Band.Columns.Add("Condition3");
					ultraDataSource.Band.Columns.Add("Connect3");
					ultraDataSource.Band.Columns.Add("Condition4");
					m_LConditionNum = 4;
				}
			}
			else
			{
				ultraDataSource.Band.Columns.Add("Condition1");
				ultraDataSource.Band.Columns.Add("Connect1");
				ultraDataSource.Band.Columns.Add("Condition2");
				ultraDataSource.Band.Columns.Add("Connect2");
				ultraDataSource.Band.Columns.Add("Condition3");
				ultraDataSource.Band.Columns.Add("Connect3");
				ultraDataSource.Band.Columns.Add("Condition4");
				m_LConditionNum = 4;
			}
			ultraDataSource.Band.Columns.Add("Interpretation");
			ultraDataSource.Band.Columns.Add("Target");
			ultraDataSource.Band.Columns.Add("Color");
			if (m_LRuleItem.RuleEditorList != null && m_LRuleItem.RuleEditorList.Count > 0)
			{
				foreach (IRuleEditor ruleEditor3 in m_LRuleItem.RuleEditorList)
				{
					object[] array = new object[num2 + 5];
					array[0] = ruleEditor3.RuleItemName;
					array[1] = ruleEditor3.RuleProperty;
					int num5 = 2;
					foreach (IConditionEditor conditionEditor3 in ruleEditor3.ConditionEditorList)
					{
						if (conditionEditor3.Condition != null)
						{
							array[num5] = conditionEditor3.Condition;
							num5++;
						}
						if (conditionEditor3.Connection != null)
						{
							array[num5] = conditionEditor3.Connection;
							num5++;
						}
					}
					array[num2 + 2] = ruleEditor3.RuleInterpretation;
					if (ruleEditor3.RuleTarget == null)
					{
						array[num2 + 3] = "";
					}
					else
					{
						array[num2 + 3] = ruleEditor3.RuleTarget;
					}
					array[num2 + 4] = ruleEditor3.RuleColorName;
					ultraDataSource.Rows.Add(array);
				}
			}
			ultraGridRule.DataSource = ultraDataSource;
			ultraGridRule.DataBind();
			ultraGridRule.DisplayLayout.Bands[0].Columns["Item"].Header.Caption = mResourceManager.GetString("ItemString");
			ultraGridRule.DisplayLayout.Bands[0].Columns["Item"].Header.Appearance.TextHAlign = HAlign.Center;
			ultraGridRule.DisplayLayout.Bands[0].Columns["Property"].Header.Caption = mResourceManager.GetString("PropertyString");
			ultraGridRule.DisplayLayout.Bands[0].Columns["Property"].Header.Appearance.TextHAlign = HAlign.Center;
			foreach (UltraGridColumn column in ultraGridRule.DisplayLayout.Bands[0].Columns)
			{
				if (column.Header.Caption.Contains("Condition"))
				{
					column.Header.Caption = mResourceManager.GetString("ConditionString") + column.Header.Caption.Replace("Condition", "");
					column.Header.Appearance.TextHAlign = HAlign.Center;
				}
			}
			ultraGridRule.DisplayLayout.Bands[0].Columns["Interpretation"].Header.Caption = mResourceManager.GetString("ConclusionString");
			ultraGridRule.DisplayLayout.Bands[0].Columns["Interpretation"].Header.Appearance.TextHAlign = HAlign.Center;
			if (m_LTargetFlag)
			{
				m_LInitalCheckTargetFlag = true;
				ultraGridRule.DisplayLayout.Bands[0].Columns["Target"].SetHeaderCheckedState(ultraGridRule.Rows, CheckState.Checked);
			}
			m_LInitalCheckTargetFlag = false;
			ultraGridRule.DisplayLayout.Bands[0].Columns["Target"].Header.CheckBoxAlignment = HeaderCheckBoxAlignment.Left;
			ultraGridRule.DisplayLayout.Bands[0].Columns["Target"].Header.CheckBoxVisibility = HeaderCheckBoxVisibility.Always;
			ultraGridRule.DisplayLayout.Bands[0].Columns["Target"].Header.Caption = mResourceManager.GetString("TargetLocationString");
			ultraGridRule.DisplayLayout.Bands[0].Columns["Target"].Header.Appearance.TextHAlign = HAlign.Center;
			if (m_LColorFlag)
			{
				m_LInitalCheckColorFlag = true;
				ultraGridRule.DisplayLayout.Bands[0].Columns["Color"].SetHeaderCheckedState(ultraGridRule.Rows, CheckState.Checked);
			}
			m_LInitalCheckColorFlag = false;
			ultraGridRule.DisplayLayout.Bands[0].Columns["Color"].Header.CheckBoxAlignment = HeaderCheckBoxAlignment.Left;
			ultraGridRule.DisplayLayout.Bands[0].Columns["Color"].Header.CheckBoxVisibility = HeaderCheckBoxVisibility.Always;
			ultraGridRule.DisplayLayout.Bands[0].Columns["Color"].Header.Caption = mResourceManager.GetString("ColorString");
			ultraGridRule.DisplayLayout.Bands[0].Columns["Color"].Header.Appearance.TextHAlign = HAlign.Center;
			foreach (UltraGridColumn column2 in ultraGridRule.DisplayLayout.Bands[0].Columns)
			{
				if (column2.Key.Contains("Connect"))
				{
					ValueList valueList = new ValueList();
					valueList.ValueListItems.Add(1, "AND");
					valueList.ValueListItems.Add(2, "OR");
					valueList.ValueListItems.Add(3, " ");
					column2.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
					column2.ValueList = valueList;
					column2.Header.Caption = " ";
				}
				if (column2.Key == "Target")
				{
					if (m_LProjectName == null)
					{
						continue;
					}
					string[] array2 = m_LProjectName.Split(new string[1] { "," }, StringSplitOptions.None);
					if (array2 == null)
					{
						continue;
					}
					ValueList valueList2 = new ValueList();
					for (int i = 0; i < array2.Length; i++)
					{
						if (array2[i] != "N/A" && array2[i] != "")
						{
							object dataValue = array2[i];
							valueList2.ValueListItems.Add(dataValue, array2[i]);
						}
					}
					valueList2.ValueListItems.Add(string.Empty, " ");
					column2.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
					column2.ValueList = valueList2;
				}
				else if (column2.Header.Caption != " ")
				{
					column2.CellActivation = Activation.NoEdit;
				}
			}
			if (m_LRuleItem.RuleEditorList == null)
			{
				UltraGridRow ultraGridRow = ultraGridRule.DisplayLayout.Bands[0].AddNew();
				if (!btDeleteRule.Enabled)
				{
					btDeleteRule.Enabled = true;
				}
				foreach (UltraGridCell cell in ultraGridRow.Cells)
				{
					if (cell.Column.Header.Caption.Contains(" "))
					{
						cell.Value = "AND";
						cell.Appearance.TextVAlign = VAlign.Middle;
						cell.Appearance.TextHAlign = HAlign.Center;
					}
					if (cell.Column.Header.Caption.Contains(mResourceManager.GetString("ItemString")))
					{
						cell.Value = mConfigurationService.GetDetectionTypeArray(PcrSystemType.AbsoluteAnalysis)[1];
						cell.Appearance.TextVAlign = VAlign.Middle;
						cell.Appearance.TextHAlign = HAlign.Center;
					}
					if (cell.Column.Key.Contains("Color"))
					{
						if (!m_LColorFlag)
						{
							object tag = Color.White.ToArgb();
							cell.Tag = tag;
							cell.Appearance.BackColor = Color.White;
							cell.Appearance.ForeColor = Color.White;
							cell.ActiveAppearance.BackColor = Color.White;
							cell.ActiveAppearance.ForeColor = Color.White;
						}
						else
						{
							object tag2 = Color.Black.ToArgb();
							cell.Tag = tag2;
							cell.Appearance.BackColor = Color.Black;
							cell.Appearance.ForeColor = Color.Black;
							cell.ActiveAppearance.BackColor = Color.Black;
							cell.ActiveAppearance.ForeColor = Color.Black;
						}
					}
					if (!(cell.Column.Key == "Target") || m_LProjectName == null)
					{
						continue;
					}
					string[] array3 = m_LProjectName.Split(new string[1] { "," }, StringSplitOptions.None);
					if (array3 == null)
					{
						continue;
					}
					ValueList valueList3 = new ValueList();
					for (int j = 0; j < array3.Length; j++)
					{
						if (array3[j] != "N/A" && array3[j] != "")
						{
							object dataValue2 = array3[j];
							valueList3.ValueListItems.Add(dataValue2, array3[j]);
						}
					}
					valueList3.ValueListItems.Add(string.Empty, " ");
					cell.Column.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
					cell.Column.ValueList = valueList3;
				}
			}
			foreach (UltraGridColumn column3 in ultraGridRule.DisplayLayout.Bands[0].Columns)
			{
				column3.PerformAutoResize(PerformAutoSizeType.AllRowsInBand);
				column3.Width += 24;
			}
		}

		protected ContextMenuStrip InitializeGridMenu()
		{
			ToolStripMenuItem toolStripMenuItem = new ToolStripMenuItem();
			toolStripMenuItem.Name = "Edit";
			toolStripMenuItem.Text = mResourceManager.GetString("EditString");
			toolStripMenuItem.Click += RuleEdit_Click;
			ContextMenuStrip contextMenuStrip = new ContextMenuStrip();
			contextMenuStrip.Items.Add(toolStripMenuItem);
			ToolStripMenuItem toolStripMenuItem2 = new ToolStripMenuItem();
			toolStripMenuItem2.Name = "Clear";
			toolStripMenuItem2.Text = mResourceManager.GetString("ClearString");
			toolStripMenuItem2.Click += RuleClear_Click;
			contextMenuStrip.Items.Add(toolStripMenuItem2);
			contextMenuStrip.Items.Add(new ToolStripSeparator());
			ToolStripMenuItem toolStripMenuItem3 = new ToolStripMenuItem();
			toolStripMenuItem3.Name = "Copy";
			toolStripMenuItem3.Text = mResourceManager.GetString("CopyString");
			toolStripMenuItem3.Click += RuleCopy_Click;
			contextMenuStrip.Items.Add(toolStripMenuItem3);
			menuRulePasteEditor = new ToolStripMenuItem();
			menuRulePasteEditor.Name = "Paste";
			menuRulePasteEditor.Text = mResourceManager.GetString("PasteString");
			menuRulePasteEditor.Click += RulePaste_Click;
			menuRulePasteEditor.Enabled = false;
			contextMenuStrip.Items.Add(menuRulePasteEditor);
			return contextMenuStrip;
		}

		private void ultraGridRule_MouseClick(object sender, MouseEventArgs e)
		{
			try
			{
				UltraGrid ultraGrid = sender as UltraGrid;
				Point point = new Point(e.X, e.Y);
				UIElement uIElement = ultraGrid.DisplayLayout.UIElement.ElementFromPoint(point);
				if (uIElement == null)
				{
					return;
				}
				if (e.Button == MouseButtons.Left)
				{
					CellUIElement cellUIElement = (CellUIElement)uIElement.GetAncestor(typeof(CellUIElement));
					if (cellUIElement != null)
					{
						if (cellUIElement.Column.Header.Caption.Contains(mResourceManager.GetString("ConditionString")) || cellUIElement.Column.Header.Caption.Contains(mResourceManager.GetString("ConclusionString")) || cellUIElement.Column.Header.Caption.Contains(mResourceManager.GetString("ItemString")))
						{
							m_LMouseClickFlag = true;
						}
						else
						{
							m_LMouseClickFlag = false;
						}
					}
				}
				else
				{
					if (e.Button != MouseButtons.Right || !m_LMouseClickFlag)
					{
						return;
					}
					CellUIElement cellUIElement2 = (CellUIElement)uIElement.GetAncestor(typeof(CellUIElement));
					if (cellUIElement2 != null && (cellUIElement2.Column.Header.Caption.Contains(mResourceManager.GetString("ConditionString")) || cellUIElement2.Column.Header.Caption.Contains(mResourceManager.GetString("ConclusionString")) || cellUIElement2.Column.Header.Caption.Contains(mResourceManager.GetString("ItemString"))) && cellUIElement2.Cell.Selected && !m_LLocked)
					{
						InitializeGridMenu().Show(ultraGrid, e.Location);
						if (m_LListCopyCondition != null && m_LListCopyCondition.Count != 0)
						{
							menuRulePasteEditor.Enabled = true;
						}
						if (m_LListCopyIntepretation != null && m_LListCopyIntepretation.Count != 0)
						{
							menuRulePasteEditor.Enabled = true;
						}
						if (m_LListCopyItem != null && m_LListCopyItem.Count != 0)
						{
							menuRulePasteEditor.Enabled = true;
						}
						m_LSelectCell = cellUIElement2.Cell;
						m_LSelectCellIndex = cellUIElement2.Column.Index;
					}
				}
			}
			catch (Exception ex)
			{
				mPcrLogService.ShowExceptionDialogBox(ex);
			}
		}

		private void RuleEdit_Click(object sender, EventArgs e)
		{
			try
			{
				RuleConditionEdit(m_LSelectCell);
			}
			catch (Exception ex)
			{
				mPcrLogService.ShowExceptionDialogBox(ex);
			}
		}

		private void RuleClear_Click(object sender, EventArgs e)
		{
			try
			{
				m_LSelectCell.Value = "";
				m_LSelectCell.Tag = null;
			}
			catch (Exception ex)
			{
				mPcrLogService.ShowExceptionDialogBox(ex);
			}
		}

		private void RuleCopy_Click(object sender, EventArgs e)
		{
			try
			{
				if (m_LSelectCell.Column.Header.Caption.Contains(mResourceManager.GetString("ConditionString")))
				{
					m_LListCopyCondition = new List<IConditionEditor>();
					if (m_LSelectCell.Text != "")
					{
						m_LCopyCondition = new ConditionEditor();
						m_LCopyCondition.Condition = m_LSelectCell.Text;
						m_LCopyCondition.ConditionIndex = m_LSelectCellIndex;
						if (m_LSelectCell.Text == "")
						{
							m_LCopyCondition.ExpressionIndex = 0;
						}
						else
						{
							m_LCopyCondition.ExpressionIndex = (int)m_LSelectCell.Tag;
						}
						m_LListCopyCondition.Add(m_LCopyCondition);
					}
					menuRulePasteEditor.Enabled = true;
					m_LMouseClickFlag = false;
					m_LListCopyIntepretation = null;
					m_LListCopyItem = null;
				}
				else if (m_LSelectCell.Column.Header.Caption.Contains(mResourceManager.GetString("ConclusionString")))
				{
					m_LListCopyIntepretation = new List<string>();
					if (m_LSelectCell.Text != "")
					{
						m_LCopyIntepretation = m_LSelectCell.Text;
						m_LListCopyIntepretation.Add(m_LCopyIntepretation);
					}
					menuRulePasteEditor.Enabled = true;
					m_LMouseClickFlag = false;
					m_LListCopyCondition = null;
					m_LListCopyItem = null;
				}
				else if (m_LSelectCell.Column.Header.Caption.Contains(mResourceManager.GetString("ItemString")))
				{
					m_LListCopyItem = new List<string>();
					if (m_LSelectCell.Text != "")
					{
						m_LListCopyItem.Add(m_LSelectCell.Text);
					}
					menuRulePasteEditor.Enabled = true;
					m_LMouseClickFlag = false;
					m_LListCopyCondition = null;
					m_LListCopyIntepretation = null;
				}
			}
			catch (Exception ex)
			{
				mPcrLogService.ShowExceptionDialogBox(ex);
			}
		}

		private void RulePaste_Click(object sender, EventArgs e)
		{
			try
			{
				if (m_LSelectCell.Column.Header.Caption.Contains(mResourceManager.GetString("ConditionString")))
				{
					if (m_LListCopyCondition == null || m_LListCopyCondition.Count == 0)
					{
						return;
					}
					foreach (UltraGridCell cell in ultraGridRule.Selected.Cells)
					{
						if (cell.Column.Key != m_LSelectCell.Column.Key)
						{
							MessageBox.Show(mResourceManager.GetString("PasteContentInvalidString"), mResourceManager.GetString("ErrorString"));
							return;
						}
					}
					foreach (UltraGridCell cell2 in ultraGridRule.Selected.Cells)
					{
						cell2.Value = m_LListCopyCondition[0].Condition;
						cell2.Tag = m_LListCopyCondition[0].ExpressionIndex;
					}
					{
						foreach (UltraGridColumn column in ultraGridRule.DisplayLayout.Bands[0].Columns)
						{
							column.PerformAutoResize(PerformAutoSizeType.AllRowsInBand);
							column.Width += 24;
						}
						return;
					}
				}
				if (m_LSelectCell.Column.Header.Caption.Contains(mResourceManager.GetString("ConclusionString")))
				{
					if (m_LListCopyIntepretation == null || m_LListCopyIntepretation.Count == 0)
					{
						return;
					}
					foreach (UltraGridCell cell3 in ultraGridRule.Selected.Cells)
					{
						if (cell3.Column.Key != m_LSelectCell.Column.Key)
						{
							MessageBox.Show(mResourceManager.GetString("PasteContentInvalidString"), mResourceManager.GetString("ErrorString"));
							return;
						}
					}
					foreach (UltraGridCell cell4 in ultraGridRule.Selected.Cells)
					{
						cell4.Value = m_LListCopyIntepretation[0];
					}
					{
						foreach (UltraGridColumn column2 in ultraGridRule.DisplayLayout.Bands[0].Columns)
						{
							column2.PerformAutoResize(PerformAutoSizeType.AllRowsInBand);
							column2.Width += 24;
						}
						return;
					}
				}
				if (!m_LSelectCell.Column.Header.Caption.Contains(mResourceManager.GetString("ItemString")) || m_LListCopyItem == null || m_LListCopyItem.Count == 0)
				{
					return;
				}
				foreach (UltraGridCell cell5 in ultraGridRule.Selected.Cells)
				{
					if (cell5.Column.Key != m_LSelectCell.Column.Key)
					{
						MessageBox.Show(mResourceManager.GetString("PasteContentInvalidString"), mResourceManager.GetString("ErrorString"));
						return;
					}
				}
				foreach (UltraGridCell cell6 in ultraGridRule.Selected.Cells)
				{
					cell6.Value = m_LListCopyItem[0];
				}
				foreach (UltraGridColumn column3 in ultraGridRule.DisplayLayout.Bands[0].Columns)
				{
					column3.PerformAutoResize(PerformAutoSizeType.AllRowsInBand);
					column3.Width += 24;
				}
			}
			catch (Exception ex)
			{
				mPcrLogService.ShowExceptionDialogBox(ex);
			}
		}

		private void RuleConditionEdit(UltraGridCell mCell)
		{
			try
			{
				if (mCell.Column.Key.Contains("Condition"))
				{
					if (mCell.Tag == null)
					{
						mCell.Tag = -1;
					}
					Condition_Editor condition_Editor = null;
					condition_Editor = (((int)mCell.Tag <= 8) ? new Condition_Editor(mApplication, mCell.Text, (int)mCell.Tag, m_LRuleItem, m_LProjectName, m_LCheck, m_LPattern, m_LTarget, m_LExpressionCheck, m_LOperator, m_LValue) : new Condition_Editor(mApplication, mCell.Text, (int)mCell.Tag, m_LRuleItem, m_LProjectName, m_LCheck, m_LPattern, m_LTarget, m_LExpressionCheck, m_LOperator, m_LValue));
					condition_Editor.ShowDialog();
					if (condition_Editor.DialogResult == DialogResult.OK)
					{
						string text = mCell.Text;
						if (text == "")
						{
							text = condition_Editor.GetSelectConditionText;
							int getSelectExpressionIndex = condition_Editor.GetSelectExpressionIndex;
							m_LCheck = condition_Editor.GetCheckIndex;
							m_LPattern = condition_Editor.GetPatternIndex;
							m_LTarget = condition_Editor.GetTargetIndex;
							m_LExpressionCheck = condition_Editor.GetExpressionCheck;
							m_LOperator = condition_Editor.GetOperatorIndex;
							m_LValue = condition_Editor.GetValueIndex;
							if (getSelectExpressionIndex > 8)
							{
								getSelectExpressionIndex -= 10;
							}
						}
						else if ((int)mCell.Tag < 0)
						{
							int getSelectExpressionIndex = 0;
						}
						else if ((int)mCell.Tag > 8)
						{
							int getSelectExpressionIndex = (int)mCell.Tag - 10;
						}
						else
						{
							int getSelectExpressionIndex = (int)mCell.Tag;
						}
						mCell.Value = condition_Editor.GetSelectConditionText;
						mCell.Tag = condition_Editor.GetSelectExpressionIndex;
						foreach (UltraGridColumn column in ultraGridRule.DisplayLayout.Bands[0].Columns)
						{
							column.PerformAutoResize(PerformAutoSizeType.AllRowsInBand);
							column.Width += 24;
						}
					}
				}
				if (!mCell.Column.Key.Contains("Interpretation"))
				{
					return;
				}
				Interpretation_Editor interpretation_Editor = new Interpretation_Editor(mCell.Text);
				interpretation_Editor.ShowDialog();
				if (interpretation_Editor.DialogResult != DialogResult.OK)
				{
					return;
				}
				mCell.Value = interpretation_Editor.GetInputInterpretation;
				foreach (UltraGridColumn column2 in ultraGridRule.DisplayLayout.Bands[0].Columns)
				{
					column2.PerformAutoResize(PerformAutoSizeType.AllRowsInBand);
					column2.Width += 24;
				}
			}
			catch (Exception ex)
			{
				mPcrLogService.ShowExceptionDialogBox(ex);
			}
		}

		private void GetProjectName()
		{
			int num = 0;
			int num2 = 0;
			m_LProjectName = null;
			string text = null;
			IProjectItem[] projectItems = m_LPcrExperimentProject.ProjectItems;
			foreach (IProjectItem projectItem in projectItems)
			{
				if (projectItem == null || !projectItem.ChannelConfiguration.IsAvailable || !projectItem.ChannelConfiguration.IsSelected)
				{
					continue;
				}
				string name = projectItem.Name;
				num2 = name.Split(',').Length;
				bool flag = false;
				if (!(name != ""))
				{
					continue;
				}
				if (m_LProjectName != null)
				{
					string[] array = m_LProjectName.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries);
					for (int j = 0; j < array.Length; j++)
					{
						if (name == array[j])
						{
							flag = true;
							break;
						}
					}
					if (!flag)
					{
						text = text + name + ",";
						num++;
					}
				}
				else
				{
					text = text + name + ",";
					num++;
				}
			}
			string[] array2 = text.TrimEnd(',').Split(',');
			for (int k = 0; k < num2; k++)
			{
				for (int l = 0; l < num; l++)
				{
					m_LProjectName = m_LProjectName + array2[k + l * num2] + ",";
				}
			}
		}

		private void ultraGridRule_AfterHeaderCheckStateChanged(object sender, AfterHeaderCheckStateChangedEventArgs e)
		{
			if (m_LLocked)
			{
				e.Column.SetHeaderCheckedState(e.Rows, CheckState.Checked);
				return;
			}
			if (e.Column.Key == "Target" && !m_LInitalCheckTargetFlag)
			{
				e.Column.GetHeaderCheckedState(e.Rows);
				if (e.Column.GetHeaderCheckedState(e.Rows) == CheckState.Checked)
				{
					m_LTargetFlag = true;
					e.Column.CellActivation = Activation.AllowEdit;
				}
				else
				{
					foreach (UltraGridRow row in ultraGridRule.Rows)
					{
						row.Cells["Target"].Value = "";
					}
					e.Column.CellActivation = Activation.NoEdit;
					m_LTargetFlag = false;
				}
			}
			if (!(e.Column.Key == "Color") || m_LInitalCheckColorFlag)
			{
				return;
			}
			if (e.Column.GetHeaderCheckedState(e.Rows) == CheckState.Checked)
			{
				foreach (UltraGridRow row2 in ultraGridRule.Rows)
				{
					row2.Cells["Color"].Tag = Color.Black.ToArgb();
					row2.Cells["Color"].Appearance.BackColor = Color.Black;
					row2.Cells["Color"].Appearance.ForeColor = Color.Black;
					row2.Cells["Color"].ActiveAppearance.BackColor = Color.Black;
					row2.Cells["Color"].ActiveAppearance.ForeColor = Color.Black;
				}
				m_LColorFlag = true;
				e.Column.CellActivation = Activation.NoEdit;
				return;
			}
			foreach (UltraGridRow row3 in ultraGridRule.Rows)
			{
				row3.Cells["Color"].Tag = Color.White.ToArgb();
				row3.Cells["Color"].Appearance.BackColor = Color.White;
				row3.Cells["Color"].Appearance.ForeColor = Color.White;
				row3.Cells["Color"].ActiveAppearance.BackColor = Color.White;
				row3.Cells["Color"].ActiveAppearance.ForeColor = Color.White;
			}
			e.Column.CellActivation = Activation.NoEdit;
			m_LColorFlag = false;
		}

		private void PopColorDialog(UltraGridCell mCell)
		{
			try
			{
				ColorDialog colorDialog = new ColorDialog();
				if (colorDialog.ShowDialog() != DialogResult.OK)
				{
					return;
				}
				mCell.Tag = colorDialog.Color.ToArgb();
				mCell.Appearance.BackColor = colorDialog.Color;
				mCell.Appearance.ForeColor = colorDialog.Color;
				mCell.ActiveAppearance.BackColor = colorDialog.Color;
				mCell.ActiveAppearance.ForeColor = colorDialog.Color;
				foreach (UltraGridColumn column in ultraGridRule.DisplayLayout.Bands[0].Columns)
				{
					column.PerformAutoResize(PerformAutoSizeType.AllRowsInBand);
					column.Width += 24;
				}
			}
			catch (Exception ex)
			{
				mPcrLogService.ShowExceptionDialogBox(ex);
			}
		}

		private void btExpression_Click(object sender, EventArgs e)
		{
			Expression_Editor expression_Editor = new Expression_Editor(mApplication, m_LRuleItem, "", m_LProjectName, m_LPattern, m_LTarget, 0, m_LOperator, m_LValue);
			expression_Editor.ShowDialog();
		}
	}
}
